{extend name="index_base" /}
      {block name="seo"}
        <title>用户设置|{$site_config['site_title']}|{$site_config['seo_title']}</title>
  
  
  <meta name="keywords" content="{$site_config['seo_keyword']}">
  <meta name="description" content="{$site_config['seo_description']}">
      {/block}
{block name="body"}
<div class="main fly-user-main layui-clear">
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
     <a href="{:url('user/home',array('id'=>$uid))}">
        <i class="layui-icon">&#xe609;</i>
        我的主页
      </a>
    </li>
     <li class="layui-nav-item  ">
      <a href="{:url('user/topic')}">
        <i class="layui-icon">&#xe612;</i>
       我的帖子
      </a>
    </li>
     <li class="layui-nav-item">
      <a href="{:url('user/comment')}">
        <i class="layui-icon">&#xe63c;</i>
        我的回复
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="{:url('user/set')}">
        <i class="layui-icon">&#xe620;</i>
        基本设置
      </a>
    </li>
    <li class="layui-nav-item  layui-this">
      <a href="{:url('user/message')}">
        <i class="layui-icon">&#xe611;</i>
        我的消息
      </a>
    </li>
  </ul>
  
  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="fly-panel fly-panel-user" pad20>
	  <div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_msg" style="margin-top: 15px;">
	   
	    <button class="layui-btn layui-btn-danger" id="LAY_delallmsg"  data-url="{:url('user/delallmessage')}" >清空全部消息</button>
	  
	    <div  id="LAY_minemsg" style="margin-top: 10px;">
       
       
       {empty name="tptc"}
        <div class="fly-none">您暂时没有最新消息</div>
       {else /}
               <ul class="mine-msg">
          
          
          
           {volist name="tptc" id="vo"}
           
           {if condition="$vo['type'] eq 2"}
          <li class="messagelist">
            <blockquote class="layui-elem-quote">
              <a href="{:url('user/home',array('id'=>$vo.userid))}" target="_blank"><cite>{$vo.username}</cite></a>回复了您的帖子<a target="_blank" href="{:url('index/thread',array('id'=>$vo['content']))}"><cite>{$vo.content|getforumbyid}</cite></a>
            </blockquote>
            <p><span>{$vo.time|friendlyDate}</span><a href="javascript:;" data-url="{:url('user/delmessage',array('id'=>$vo['id']))}" class=" elementdel layui-btn layui-btn-small layui-btn-danger fly-delete">删除</a></p>
          </li>
          {else /}
           <li class="messagelist">
            <blockquote class="layui-elem-quote">
              系统消息：{$vo.content|htmlspecialchars_decode}
            </blockquote>
            <p><span>{$vo.time|friendlyDate}</span><a href="javascript:;"   data-url="{:url('user/delsysmessage',array('id'=>$vo['id']))}" class=" elementdel layui-btn layui-btn-small layui-btn-danger fly-delete">删除</a></p>
          </li>
           {/if}
            {/volist}
          
          
        </ul>
        <div class="pages cl">
          
          {$tptc->render()}</div>
       
       
{/empty}

       

       
      </div>
	  </div>
	</div>

</div>
{/block}
{block name="script"}
<script>
layui.use(['layer','jquery','form'],function(){
  var layer = layui.layer
  , form = layui.form()
  ,jq = layui.jquery;
  
  jq('#LAY_delallmsg').click(function(){
		var url=  jq(this).data('url');
		
	if(	jq('.messagelist').length>0){
		layer.confirm('你确定要删除所有消息吗?', {icon: 3, title:'删除提示'}, function(index){
			 loading = layer.load(2, {
			      shade: [0.2,'#000']
			    });
		   
			  
			    jq.getJSON(url,function(data){
			      if(data.code == 200){
			        layer.close(loading);
			        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
			         // 
			        	
			        		 location.reload();
			      
			          
			        });
			      }else{
			        layer.close(loading);
			        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			      }
			    });
			
		});
	}else{
		 layer.msg('您无任何消息可删除', {icon: 2, anim: 6, time: 1000});
	}
		
		

	  });
  
  jq('.elementdel').click(function(){
	  
	//  var id= jq(this).data('id');
	  var url= jq(this).data('url');

 
  //alert(locationurl);
 // alert(window.location.href);
  layer.confirm('你确定要删除该条消息吗?', {icon: 3, title:'删除提示'}, function(index){
		    loading = layer.load(2, {
			      shade: [0.2,'#000']
			    });
		   
			  
			    jq.getJSON(url,function(data){
			      if(data.code == 200){
			        layer.close(loading);
			        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
			         // 
			        	
			        		 location.reload();
			      
			          
			        });
			      }else{
			        layer.close(loading);
			        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			      }
			    });
		 
		}); 
	  
	  

	  });



	  
  });
  
  </script>
{/block}